<?php
if (!defined('BASEPATH'))
    exit('No direct script access allowed');
/**
 * View file: form
 *
 * @author luubk
 * @since 10-06-2012 - 01:36:22
 */
?>
<div id="form_result"></div>
<article class="module width_full">
    <form method="POST" id="form" 
          action="<?php echo $id ? site_url("user/form/$id") : site_url("user/form") ?>">
        <header><h3><?php echo $title ?></h3></header>
        <div class="module_content">
            <fieldset style="width:48%; float:left; margin-right: 3%;">
                <label>Tên tài khoản</label>
                <input type="text" style="width:92%;"
                       value="<?php echo isset($item['u_name']) ? $item['u_name'] : '' ?>"
                       name="u_name" required="required">
            </fieldset>
            <fieldset style="width:48%; float:left;">
                <label>Mật khẩu</label>
                <input type="text" style="width:92%;"                       
                       name="u_pass" <?php echo $id ? '' : 'required="required"' ?>>
                <?php echo $id ? 'Để trống nếu giữ nguyên mật khẩu cũ' : '' ?>
            </fieldset>
            <div class="clear"></div>
            <fieldset style="width:48%; float:left; margin-right: 3%;">
                <label>Email</label>
                <input type="text" style="width:92%;" 
                       value="<?php echo isset($item['u_email']) ? $item['u_email'] : '' ?>"
                       name="u_email">
            </fieldset>
            <fieldset style="width:48%; float:left;">
                <label>Số điện thoại</label>
                <input type="text" style="width:92%;" 
                       value="<?php echo isset($item['u_phone']) ? $item['u_phone'] : '' ?>"
                       name="u_phone">
            </fieldset>
            <div class="clear"></div>
            <fieldset style="width:48%; float:left; margin-right: 3%;">
                <label>Nhóm</label>
<!--                <select style="width:92%;" name="ug_id">
                    <?php foreach ($group as $grp): ?>
                        <option value="<?php echo $grp['ug_id'] ?>"
                        <?php
                        if (isset($item['u_group_ids']))
                            if (in_array($grp['ug_id'], $item['u_group_ids']))
                                echo 'selected="selected"';
                        ?>>
                                    <?php echo $grp['ug_name'] ?>
                        </option>                    
                    <?php endforeach; ?>
                </select>-->
                <div style="clear: both"></div>
                <?php foreach ($group as $grp): ?>
                    <input type="checkbox" name="ug_id[]" value="<?php echo $grp['ug_id'] ?>" 
                        <?php
                        if (isset($item['u_group_ids']))
                            if (in_array($grp['ug_id'], $item['u_group_ids']))
                                echo 'checked';
                        ?>> <?php echo $grp['ug_name'] ?> <br>
                <?php endforeach; ?>
            </fieldset>
            <div class="clear"></div>
        </div>
        <footer>
            <div class="submit_link">
                <span class="loading">&nbsp;</span>
                <select name="u_status">
                    <option value="1" <?php echo (isset($item['u_status']) && $item['u_status'] == 1) ? 'selected="selected"' : '' ?>>Kích hoạt</option>
                    <option value="0" <?php echo (isset($item['u_status']) && $item['u_status'] == 0) ? 'selected="selected"' : '' ?>>Vô hiệu hóa</option>
                </select>
                <input type="submit" value="Lưu lại" class="alt_btn">
                <input type="reset" value="Nhập lại">                
            </div>
        </footer>
    </form>
</article><!-- end of post new article -->
